package com.second.app.proxy.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @Author GYZ
 * @Date 2023/9/19
 * <pre>
 *
 * </pre>
 */

@Aspect
@Component
public class LoginAspect {

    @Pointcut("execution(public * com.second.app.proxy.ProductServiceImpl.*(..))")
    public void pointCut() {

    }

    @Before(value = "pointCut()")
    public void before(JoinPoint point) {
        System.out.println("【记录日志】准备执行方法：" + point.getSignature().getName() + ",参数列表：" + Arrays.toString(point.getArgs()));
    }

    @AfterReturning(value = "pointCut()", returning = "result")
    public void afterReturning(JoinPoint point, Object result) {
        System.out.println("【记录日志】方法执行结束：" + point.getSignature().getName() + ",返回值为：" + result);
    }
}
